package com.yq.service.impl;

import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.yq.core.entity.SysDepartmentEntity;
import com.yq.core.service.SysDepartmentService;
import com.yq.core.util.Page;
import com.yq.service.annotation.AzerothAutoService;
import com.yq.service.dao.BaseMapper;
import com.yq.service.dao.SysDepartmentMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;


/**
 * 信  息: [yinquan] [2017-05-04] [1.0]
 * 描  述: Service 实现
 */
@AzerothAutoService("sysDepartmentService")
public class SysDepartmentServiceImpl extends BaseServiceImpl<SysDepartmentEntity, String> implements SysDepartmentService {

    private static Logger logger = LoggerFactory.getLogger(SysDepartmentServiceImpl.class);

    @Autowired
    private SysDepartmentMapper sysDepartmentMapper;

    public BaseMapper<SysDepartmentEntity, String> getBaseMapper() {
        return sysDepartmentMapper;
    }

    /** 部门列表查询 **/
    public Page<Map<String, Object>> pageDepList(Map<String, Object> parameter, Page page) {
        PageBounds pageBounds = new PageBounds(page.getPageCurrent(), page.getPageSize(), true);
        List<Map<String, Object>> list = sysDepartmentMapper.pageDepList(parameter, pageBounds);
        PageList<Map<String, Object>> pageList = (PageList) list;
        page.setRows(pageList);
        page.setTotalPageNum(pageList.getPaginator().getTotalPages());// 总页数
        page.setTotal(pageList.getPaginator().getTotalCount());// 总记录数
        return page;
    }

    /** 获取部门列表 **/
    public List<Map<String, Object>> pageDepAllList(Map<String, Object> parameter) {
        return sysDepartmentMapper.pageDepAllList(parameter);
    }

}